<?php

/**
 * Name: 用户信息验证层
 * User: Silent
 * Date: 2025-01-30
 * Time: 10:00:00
 */

namespace App\Http\Requests\Auth;

use Illuminate\Foundation\Http\FormRequest;

class UserRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'headimgurl' => 'sometimes|string|url',
            'job'        => 'sometimes|string|max:50',
            'job_id'     => 'sometimes|integer|min:1',
            'name'       => 'sometimes|string|max:10',
            'nickname'   => 'sometimes|string|max:10',
            'phone'      => 'sometimes|string|regex:/^1[3-9]\d{9}$/',
            'team'       => 'sometimes|string|max:100',
            'team_id'    => 'sometimes|integer|min:0',
        ];
    }

    public function messages(): array
    {
        return [
            'headimgurl.url'     => '头像链接格式不正确',
            'job.max'            => '职位长度不能超过50个字符',
            'job_id.integer'     => '职位ID必须是整数',
            'job_id.min'         => '职位ID必须大于0',
            'name.max'           => '姓名长度不能超过10个字符',
            'nickname.max'       => '昵称长度不能超过10个字符',
            'phone.regex'        => '手机号格式不正确',
            'team.max'           => '团队名称长度不能超过100个字符',
            'team_id.integer'    => '团队ID必须是整数',
            'team_id.min'        => '团队ID不能小于0',
        ];
    }
}
